import request from '@/utils/request'

// 获取职位列表
export function getPositions(params) {
  return request({
    url: '/api/positions',
    method: 'get',
    params
  })
}

// 获取当前位置
export function getCurrentLocation() {
  return new Promise((resolve, reject) => {
    uni.getLocation({
      type: 'gcj02',
      success: (res) => {
        resolve({
          latitude: res.latitude,
          longitude: res.longitude,
          city: res.city || '未知'
        })
      },
      fail: (err) => {
        reject(err)
      }
    })
  })
}

// 搜索职位
export function searchPositions(keyword) {
  return request({
    url: '/api/positions/search',
    method: 'get',
    params: { keyword }
  })
} 